# 项目:
# 文件: demo2
# 作者: Yang
# 日期: 2025/5/23 11:07
# coding:utf-8

class Cacl:

    def __init__(self,num_a,num_b):
        self.num_a = num_a
        self.num_b = num_b

    def add(self):
        print(f'两个数的和为{self.num_a + self.num_b}')

    def minus(self):
        print(f'两个数的差为{self.num_a - self.num_b}')

    def mul(self):
        print(f'两个数的积为{self.num_a * self.num_b}')

    def div(self):
        try:
            print(f'两个数的商为{self.num_a / self.num_b}')
        except Exception as e:
                print(e)
                print("数据有误")

if __name__ == '__main__':
    num_a = int(input('请输入第一个值'))
    num_b = int(input('请输入第二个值'))
    operator = input("请输入运算符号")
    cacl = Cacl(num_a,num_b)
    if hasattr(cacl,operator):
        getattr(cacl,operator)()
    else:
        print("有误")


